package com.faradel.pharmapp.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.faradel.pharmapp.entities.OrderMedication;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.faradel.pharmapp.dao.OrderMedicationDAO;

@Repository("orderMedicationServiceImpl")
public class OrderMedicationServiceImpl implements OrderMedicationServiceInterface
{
    @Resource
    OrderMedicationDAO orderMedicationDaoImpl;

    @Override
    @Transactional(readOnly = false)
    public void addOrderMedication(OrderMedication orderMed)
    {
        orderMedicationDaoImpl.save(orderMed);
    }

    @Override
    @Transactional(readOnly = false)
    public void updateOrderMedication(OrderMedication orderMed)
    {
        orderMedicationDaoImpl.update(orderMed);
    }

    @Override
    @Transactional(readOnly = false)
    public void deleteOrderMedication(OrderMedication orderMed)
    {
        orderMedicationDaoImpl.delete(orderMed);
    }

    @Override
    @Transactional(readOnly = true)
    public OrderMedication getOrderMedicationById(int id)
    {
        return orderMedicationDaoImpl.get(id);
    }

    @Override
    @Transactional(readOnly = true)
    public List<OrderMedication> getAllOrderMedication()
    {
        return orderMedicationDaoImpl.selectAll();
    }

    @Override
    @Transactional(readOnly = true)
    public List<OrderMedication> getOrderMedicationByColumns(Map<String, String> map)
    {
        return orderMedicationDaoImpl.findByColumn(map);
    }

}
